package com.example.webcrawler.model;

import com.google.gson.JsonObject;
import com.microsoft.playwright.CDPSession;
import com.microsoft.playwright.Page;
import lombok.Data;

import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

@Data
public class DebugSession {
        private final String id;
        private final Page page;
        private final CDPSession cdpSession;
        private boolean paused;
        private String pauseReason;
        private JsonObject pauseData;
        private long startTime; // 会话开始时间
        private long pauseTime; // 暂停时间
        private int hitCount; // 断点命中次数

        // 新增: 会话状态
        private String status; // active, paused, completed, error
        private List<String> callStack; // 调用栈信息
        private Map<String, Object> variables; // 变量信息
        private List<Breakpoint> breakpoints; // 断点列表

        public DebugSession(String id, Page page, CDPSession cdpSession) {
                this.id = id;
                this.page = page;
                this.cdpSession = cdpSession;
                this.paused = false;
                this.startTime = System.currentTimeMillis();
                this.hitCount = 0;
                this.status = "active";
                this.callStack = new ArrayList<>();
                this.variables = new HashMap<>();
                this.breakpoints = new ArrayList<>();
        }

        public void incrementHitCount() { this.hitCount++; }


}
